package ru.autofan.logic.support;

import org.springframework.web.multipart.MultipartFile;

import ru.autofan.domain.FotoType;

public class FotoTypeExtracter {
	
	public FotoType extract(MultipartFile file) {
		if (file.getOriginalFilename().endsWith("jpg") || 
				file.getOriginalFilename().endsWith("jpeg")) {
			return FotoType.JPG;
		} else if (file.getOriginalFilename().endsWith("png")) {
			return FotoType.PNG;
		} else if (file.getOriginalFilename().endsWith("gif")) {
			return FotoType.GIF;
		} else {
			return FotoType.DEFAULT;
		}
	}

}
